package com.black.cat.seed.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author blackcat
 * @create 2020/9/11 20:57
 * @version: 1.0
 * @description:
 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //获取当前操作系统
        String osName = System.getProperty("os.name");
        //如果是windows
        if (osName.toLowerCase().startsWith("win")) {
            registry.addResourceHandler("/filedata/**")
                    .addResourceLocations("file:C:/filedata/");
        } else {
            //linux或者mac
            registry.addResourceHandler("/filedata/**")
                    .addResourceLocations("file:/filedata/");
        }
    }
}